// 用户模块数据库操作
const db = require('./db.js')

module.exports = {
  // 登录查询
  Login: async (userName, password) => {
    // 定义sql语句
    const sql = 'select * from users where userName = ? and password = ?'
    return await db.query(sql, [userName, password])
  },
  // 查询用户是否存在
  FindUserName: async (userName) => {
    const sql = 'select * from users where userName = ?'
    return await db.query(sql, [userName])
  },
  // 添加用户
  Register: async (userName, password) => {
    const sql = 'insert into users values(null,?,?,null)'
    return await db.query(sql, [userName, password])
  }
}
